# 利用eval方法进行执行
class Foo():

    def execute(self,method, *args, **kwargs):
        assert method in ['hdbscan', 'dbscan'], 'Invalid method chosen.'
        method = eval('self.' + method)
        # 执行方法
        self.algorithm = method(*args, **kwargs)

    def hdbscan(self,*args, **kwargs):
        print("hdbscan",*args, **kwargs)

    def dbscan(self,*args, **kwargs):
        print("dbscan",*args, **kwargs)

foo=Foo()
foo.execute("dbscan", "a")